package IceAssembly;

import java.io.*;
import java.util.*;

/**
 *
 * @author Peter Dietz
 */
public class Misc {
    
    /**
    * Compares two files to find out if they are identical
    * <p>
    * <b>Change Log:</b><br>
    * 04/26/08 - Thought up need for operation - Peter Dietz<br>
    * 04/27/08 - Coded the operation - Yogesh Jindal<br>
    * 04/27/08 - Documented the operation - Peter Dietz<br>
    * <p>
    * <b>Error Conditions Tested:</b><br>
    * INTERNAL: File I/O Errors, such as file doesn't exist<br>
    * <p>
    * <b>Date of module being installed:</b> 04/27/08
    * @author Yogesh Jindal
    * @param file1 
    * @param file2 
    * @return "1" if the files were identical, "0" if the files were different
    */
    public String CompareFiles (String file1, String file2) throws java.io.IOException{
        String file1_string="",file2_string="";

        //Reading the contents of the files
        BufferedReader br_file1 = new BufferedReader (new FileReader (file1));
        BufferedReader br_file2 = new BufferedReader (new FileReader (file2));
        String temp="";
        while((temp=br_file1.readLine())!=null){
            file1_string+=temp;
        }
        temp="";
        while((temp=br_file2.readLine())!=null){
            file2_string+=temp;
        }
        if(file1_string.contentEquals(file2_string)){
            return "1";
        }
        return "0";
    }
}